package com.future.direction.ui.activity;

import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.CacheUtils;
import com.future.direction.R;
import com.future.direction.common.util.PopuUtil;
import com.future.direction.common.util.UIUtil;
import com.future.direction.di.component.AppComponent;
import com.future.direction.ui.widget.MyPopupWindow;
import com.future.direction.ui.widget.MyTitleBar;

import butterknife.BindView;

/**
 * Created by zhp on 2019-11-20
 */
public class CourseDetailsActivity extends BaseActivity {
    @BindView(R.id.titleBar)
    MyTitleBar titleBar;
    @BindView(R.id.button_course_join)
    Button buttonCourseJoin;
    @BindView(R.id.rl_content)
    RelativeLayout rlContent;


    @Override
    public int setLayout() {
        return R.layout.activity_course_details;
    }

    @Override
    public void getExtras() {

    }

    @Override
    public boolean init() {
        backListener(titleBar);
        buttonCourseJoin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                joinCourse();
            }
        });
        return false;
    }

    @Override
    public void setListener() {

    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

    private void joinCourse() {
        MyPopupWindow courseJoin = new PopuUtil().initAtLocationPopuWrap(this,
                R.layout.popup_course_join, rlContent, 311, 176);
        TextView tvCourseJoinName = courseJoin.getContentView().findViewById(R.id.tv_course_join_name);
        TextView tvCourseJoinPhone = courseJoin.getContentView().findViewById(R.id.tv_course_join_phone);
        Button buttonPopupCancel = courseJoin.getContentView().findViewById(R.id.button_creat_cancel);
        Button buttonPopupCommitSure = courseJoin.getContentView().findViewById(R.id.button_creat_commit_sure);
        buttonPopupCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                courseJoin.dismiss();
            }
        });
        buttonPopupCommitSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CacheUtils.getInstance().clear();
                UIUtil.showLongToastSafe("报名成功");
                courseJoin.dismiss();
            }
        });
    }

}
